package group2assignone.ucm.manager;

import group2assignone.dao.MyDAO;
import group2assignone.model.Flight;
import group2assignone.ucm.UCController;
import group2assignone.ucm.UCStartup;
import group2assignone.view.manager.DeleteFlightView;
import group2assignone.view.manager.ManagerView;

/**
 * use case to delete a flight
 * @author group2
 */
public class UCDeleteFlight implements UCController {

    private DeleteFlightView deleteView = new DeleteFlightView();
    private Flight f = new Flight();

    /**
     * sets view and flight
     * @param dView
     * @param flight
     */
    public UCDeleteFlight(DeleteFlightView dView, Flight flight) {
        deleteView = dView;
        f = flight;
    }

    @Override
    public void run() {

        MyDAO coms = UCStartup.getInstance().getDAO();
        coms.sQLDeleteFlight(deleteView.getFlightNum());
        //go back to main login screen
        deleteView.dispose();
        ManagerView mv = ManagerView.getInstance();
        mv.setVisible(true);
    }
}
